﻿using System;
using System.Collections.Generic;

namespace IceCS.DesignPattern.Core.FlyweightPattern.CirclePool
{
    /// <summary>
    /// 图形工厂
    /// </summary>
    public static class ShapeFactory
    {
        public static Dictionary<string, IShapeAction> Pool { get; set; }

        static ShapeFactory()
        {
            Pool = new Dictionary<string, IShapeAction>();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="color"></param>
        /// <returns></returns>
        public static IShapeAction GetCircle(string color)
        {
            if (!Pool.ContainsKey(color))
            {
                Pool.Add(color, new Circle(color));
                Console.WriteLine($"create circle:{color}");
            }
            return Pool[color];
        }
    }
}

